package out1;

class Math implements Cloneable
{
    public int n=11;

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}
/*class Person implements Cloneable
{
    int m=10;

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}

 */
class Person implements Cloneable
{
    public int m=10;
    public Math math=new Math();



    @Override
    protected Object clone() throws CloneNotSupportedException {
        Person tmp=(Person)(super.clone());
        tmp.math= (Math) (this.math.clone());
        return tmp;
    }
}



public class text10 {
    public static void main(String[] args) throws CloneNotSupportedException{
        Person person1=new Person();
        Person  person2=(Person)(person1.clone());
        person2.math.n=19;
        System.out.println(person1.math.n);
        System.out.println(person2.math.n);




    }
    public static void main2(String[] args) throws CloneNotSupportedException{
        Person person2=new Person();
        person2.math.n=19;
       Person person3=(Person)(person2.clone());

        System.out.println(person2.math.n);
        System.out.println(person3.math.n);

    }
    public static void main1(String[] args)throws CloneNotSupportedException {
        Person person1=new Person();
        person1.m=20;
        Person person2=(Person)(person1.clone());
        System.out.println( person1.m);
        System.out.println(person2.m);
    }




}
